Telegram Group & Telegram Channel
🧠 Python-хитрая задача + решение

🖍️ Условие:
У тебя есть список логов (user, login/logout).
Найди тех, кто зашел, но не вышел.

📜 Пример:

logs = [
("alice", "login"),
("bob", "login"),
("alice", "logout"),
("dave", "login"),
("bob", "logout"),
("carol", "login"),
("dave", "logout")
]


________
💻 Решение:

from collections import defaultdict

def find_stuck_users(logs):
counter = defaultdict(int)
for user, action in logs:
if action == "login":
counter[user] += 1
elif action == "logout":
counter[user] -= 1
return sorted([user for user, count in counter.items() if count > 0])


🛠Ответ: "carol"

#Python #Challenge #DevPuzzle

@python_job_interview



tg-me.com/python_testit/1161
Create:
Last Update:

🧠 Python-хитрая задача + решение

🖍️ Условие:
У тебя есть список логов (user, login/logout).
Найди тех, кто зашел, но не вышел.

📜 Пример:


logs = [
("alice", "login"),
("bob", "login"),
("alice", "logout"),
("dave", "login"),
("bob", "logout"),
("carol", "login"),
("dave", "logout")
]


________
💻 Решение:

from collections import defaultdict

def find_stuck_users(logs):
counter = defaultdict(int)
for user, action in logs:
if action == "login":
counter[user] += 1
elif action == "logout":
counter[user] -= 1
return sorted([user for user, count in counter.items() if count > 0])


🛠Ответ: "carol"

#Python #Challenge #DevPuzzle

@python_job_interview

BY Python tests


Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283

Share with your friend now:
tg-me.com/python_testit/1161

View MORE
Open in Telegram


Python tests Telegram | DID YOU KNOW?

Date: |

The messaging service and social-media platform owes creditors roughly $700 million by the end of April, according to people briefed on the company’s plans and loan documents viewed by The Wall Street Journal. At the same time, Telegram Group Inc. must cover rising equipment and bandwidth expenses because of its rapid growth, despite going years without attempting to generate revenue.

Python tests from jp


Telegram Python tests
FROM USA